package com.cheejee.goodscenter.util;

import javax.annotation.Resource;

import com.cheejee.goodscenter.module.entity.Goods;
import com.cheejee.goodscenter.service.GoodsService;

import cn.hutool.cron.task.Task;

/**
 * 商品上下架任务，用于商品定时上下架
 * @author CARRY
 * @Date 2020年10月27日上午1:19:51
 */
public class GoodsUpAndDownTask implements Task{
	
	@Resource
	private GoodsService service;
	
	private Long goodsId;
	private Boolean type;
	
	public GoodsUpAndDownTask(Long goodsId, Boolean type) {
		this.goodsId = goodsId;
		this.type = type;
	}

	@Override
	public void execute() {
		Goods goods = new Goods();
		goods.setId(goodsId);
		goods.setIsOn(type);
		service.changeGoods(goods);
	}

}
